package com.thread.async.future;

import java.util.concurrent.*;

/**
 * Created by zhuangqi on 17-6-17.
 */
public class NettyTest {

    public static void main(String[] args) {
        //实现一个Callable接口
        Callable<Netty> c = new Callable<NettyTest.Netty>() {

            @Override
            public Netty call() throws Exception {

                //这里是你的业务逻辑处理

                //让当前线程阻塞5秒看下效果
                Thread.sleep(5000);
                return new Netty("张三");
            }
        };
        FutureTask.doTask(c);
        System.out.println("主线任务已经执行完了");
        FutureTask.getResult();
    }

    static class Netty {

        private Netty(String name) {
            this.name = name;
        }
        public String name;
    }
}
